<template>
<div>
  <h1>添加分类</h1>
  <p><input type="text" v-model="from.name"></p>
  <p></p><br><br>
  <select name="" id="" v-model="from.parent">
    <option :value="i.id" v-for="i in classifylist">{{i.name}}</option>
  </select><br><br>
  <button @click="post_classify">添加</button>
</div>
</template>

<script>
export default {
name: "add_classify",
  data(){
    return{
      from:{},
      classifylist:[]
    }
  },
  methods:{
    post_classify(){
      this.$axios.post('users/classify/',this.from).then(res=>{
        if(res.data.code==200){
          alert('添加成功')
          this.get_classify()
          this.from={}
        }
      })
    },
    get_classify(){
      this.$axios.get('users/classify/').then(res=>{
        if(res.data.code==200){
          this.classifylist=res.data.matter
        }
      })
    }
  },
  mounted() {
    this.get_classify()
  }
}
</script>

<style scoped>

</style>